import {axios} from "../../api/http.js";
import {GetOrder} from "../../api/Url.js"
Page({

  /**
   * 页面的初始数据
   */
  data: {
    nbTitle: '商品状态',
    currentData: 0,
    orderList:[],
    key:[
      {
        index:"0",
        text:"代付款"
      },
      {
        index:"1",
        text:"待发货"
      },
      {
        index:"2",
        text:"待收款"
      },
      {
        index:"3",
        text:"待评价"
      },
      {
        index:"5",
        text:"退货/售后"
      },
    ],
    current_scroll: '0'
  },
  handleChangeScroll ({ detail }) {
    console.log(detail)
    axios(GetOrder,{orderStatus:detail.key},"post",(res)=>{
      console.log(res)
      this.setData({
        current_scroll: detail.key,
        orderList:res
      })
      console.log(this.data.current_scroll)
    })
},
  gotocomment(){
     wx.navigateTo({
       url: '../comment/comment',
     })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

    console.log(options)
    axios(GetOrder,{orderStatus:options.orderStatus},"post",(res)=>{
      console.log(res)
      this.setData({
        currentData:options.orderStatus,
        orderList:res
      })
    })
  },
  
  // //获取当前滑块的index
  // bindchange: function (e) {
  //   const that = this;
  //   axios(GetOrder,{orderStatus:e.target.dataset.current},"post",(res)=>{
  //     console.log(res)
  //     that.setData({
  //       currentData:e.target.dataset.current,
  //       orderList:res
  //     })
  //   })
  //   that.setData({
  //     currentData: e.detail.current
  //   })
  // },


  // //点击切换，滑块index赋值
  // checkCurrent: function (e) {
  //   const that = this;
  //   console.log(e)
  //   if (that.data.currentData === e.target.dataset.current) {
  //     return false;
  //   } else {
  //     axios(GetOrder,{orderStatus:e.target.dataset.current},"post",(res)=>{
  //       console.log(res)
  //       that.setData({
  //         currentData:e.target.dataset.current,
  //         orderList:res
  //       })
  //     })
  //   }
  // }
})